local zhijiu = fk.CreateSkill {
  name = "lingling__zhijiu",
}

Fk:loadTranslationTable {
  ["lingling__zhijiu"] = "置酒",
  [":lingling__zhijiu"] = "你可以将装备牌当【酒】使用（每回合限一次）；你可以用装备区的牌拼点。",

  ["#lingling__zhijiu"] = "置酒：将装备牌当【酒】使用",
  ["#lingling__zhijiu-invoke"] = "置酒：你可以用装备区内一张牌拼点",
  ["#lingling__zhijiu-choose"] = "置酒：请选择装备区内一张牌拼点",
}

zhijiu:addEffect("viewas", {
  anim_type = "support",
  pattern = "analeptic",
  prompt = "#lingling__zhijiu",
  handly_pile = true,
  max_turn_use_time = 1,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).type == Card.TypeEquip
  end,
  view_as = function(self, player, cards)
    if #cards ~= 1 then return end
    local card = Fk:cloneCard("analeptic")
    card.skillName = zhijiu.name
    card:addSubcard(cards[1])
    return card
  end,
  enabled_at_play = function (self, player)
    return self:withinTimesLimit(player, Player.HistoryTurn)
  end,
  enabled_at_response = function(self, player, response)
    return not response and self:withinTimesLimit(player, Player.HistoryTurn)
  end,
})

zhijiu:addEffect(fk.StartPindian, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(zhijiu.name) and (player == data.from or table.contains(data.tos, player)) and
        #player:getCardIds("e") > 0
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = zhijiu.name,
      prompt = "#lingling__zhijiu-invoke"
    })
  end,
  on_use = function(self, event, target, player, data)
    local card = player.room:askToCards(player, {
      min_num = 1,
      max_num = 1,
      pattern = tostring(Exppattern:new { id = player:getCardIds("e") }),
      include_equip = true,
      prompt = "#lingling__zhijiu-choose",
      skill_name = zhijiu.name,
      cancelable = false,
    })[1]
    if player == data.from then
      data.fromCard = Fk:getCardById(card)
    else
      data.results[player] = data.results[player] or {}
      data.results[player].toCard = Fk:getCardById(card)
    end
  end,
})

zhijiu:addAI(nil, "vs_skill")

return zhijiu
